package mqtt_connector

import "github.com/sirupsen/logrus"

type MqttLogger struct {
	Log   *logrus.Logger
	Level logrus.Level
}

func (m *MqttLogger) Println(v ...interface{}) {
	switch m.Level {
	case 0:
		m.Log.Panicln(v...)
	case 1:
		m.Log.Fatalln(v...)
	case 2:
		m.Log.Errorln(v...)
	case 3:
		m.Log.Warnln(v...)
	case 4:
		m.Log.Infoln(v...)
	case 5:
		m.Log.Debugln(v...)
	case 6:
		m.Log.Traceln(v...)
	default:
		m.Log.Debugln(v...)
	}
}

func (m *MqttLogger) Printf(format string, v ...interface{}) {
	switch m.Level {
	case 0:
		m.Log.Panicf(format, v...)
	case 1:
		m.Log.Fatalf(format, v...)
	case 2:
		m.Log.Errorf(format, v...)
	case 3:
		m.Log.Warnf(format, v...)
	case 4:
		m.Log.Infof(format, v...)
	case 5:
		m.Log.Debugf(format, v...)
	case 6:
		m.Log.Tracef(format, v...)
	default:
		m.Log.Debugf(format, v...)
	}
}
